package com.yanqu.road.server.cmd.activity.union;

import com.yanqu.road.entity.servercenter.ServerInfo;
import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.pb.activity.ChannelTonBingProto;
import com.yanqu.road.pb.union.cross.CrossUnionProto;
import com.yanqu.road.server.cmd.CrossCommand;
import com.yanqu.road.server.command.Cmd;
import com.yanqu.road.server.connect.CrossAgentLinkedControl;
import com.yanqu.road.server.logic.MessageHelper;
import com.yanqu.road.server.manager.union.CrossUnionMgr;
import com.yanqu.road.server.manger.ServerListMgr;
import com.yanqu.road.server.protocol.ChannelProtocol;
import com.yanqu.road.server.protocol.CrossProtocol;
import com.yanqu.road.utils.RandomHelper;
import com.yanqu.road.utils.YanQuMessageUtils;

import java.util.ArrayList;
import java.util.List;

@Cmd(code = CrossProtocol.C2_CHANNEL_ACTIVITY_GET_UNION_INFO_BACK, desc = "")
public class Cross3GetUnionReqBackCmd extends CrossCommand {

    @Override
    public boolean parseData(YanQuMessage packet) throws Exception {
        return true;
    }

    @Override
    public void execute(YanQuMessage packet) throws Exception {
        CrossUnionProto.ChannelGetUnionMaxAbilityRankListResp reqMsg = CrossUnionProto.ChannelGetUnionMaxAbilityRankListResp.parseFrom(packet.getBytes());
        List<ServerInfo> serverInfoList = ServerListMgr.getChannelServerList(reqMsg.getChannel());
        List<Long> serverIdList = new ArrayList<>();
        for(ServerInfo serverInfo : serverInfoList){
            serverIdList.add(serverInfo.getServerId());
        }
        CrossUnionProto.ChannelGetUnionMaxAbilityRankListResp.Builder builder = reqMsg.toBuilder();
        builder.addAllServerId(serverIdList);
        MessageHelper.sendChannelServer(YanQuMessageUtils.buildMessage(ChannelProtocol.N_ACTIVITY_GET_UNION_INFO_RESP, builder));
    }

    @Override
    public void sendData() {

    }

}
